
#include "midea_base_scroll_cell.h"
#include "midea_base_scroll_btn_cell.h"
#include <stdio.h>

/*********************
 *      DEFINES
 *********************/
#define MY_CLASS &midea_base_scroll_btn_cell_class

/**********************
 *      TYPEDEFS
 **********************/

/**********************
 *  STATIC PROTOTYPES
 **********************/
static void midea_base_scroll_btn_cell_constructor(const lv_obj_class_t *class_p, lv_obj_t *obj);
static void midea_base_scroll_btn_cell_destructor(const lv_obj_class_t *class_p, lv_obj_t *obj);
/**********************
 *  STATIC VARIABLES
 **********************/
const lv_obj_class_t midea_base_scroll_btn_cell_class = {
    .constructor_cb = midea_base_scroll_btn_cell_constructor,
    .destructor_cb = midea_base_scroll_btn_cell_destructor,
    .width_def = LV_PCT(100),
    .height_def = LV_SIZE_CONTENT,
    // .group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE,
    // .instance_size = sizeof(lv_btn_t),
    .base_class = &midea_base_scroll_cell_class};

/**********************
 *      MACROS
 **********************/

/**********************
 *   GLOBAL FUNCTIONS
 **********************/

lv_obj_t *midea_base_scroll_btn_cell_create(lv_obj_t *parent)
{
    // LV_LOG_INFO("begin");
    lv_obj_t *cell = lv_obj_class_create_obj(MY_CLASS, parent);
    lv_obj_class_init_obj(cell);
    midea_base_scroll_cell *base_cell = (midea_base_scroll_cell *)cell;
    base_cell->ui_type = ((1 << 8) - 2); // 为了让初始化的ui_type不常用 不和常用的冲突
    return cell;
}

/**********************
 *   STATIC FUNCTIONS
 **********************/

static void midea_base_scroll_btn_cell_constructor(const lv_obj_class_t *class_p, lv_obj_t *obj)
{
    LV_UNUSED(class_p);
    // LV_TRACE_OBJ_CREATE("begin");

    lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE);
    lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS);

    // DARK_COLOR_GREY

    lv_obj_set_style_bg_color(obj, lv_color_hex(0xcccccc), LV_STATE_PRESSED);
    lv_obj_set_style_bg_opa(obj, LV_OPA_40, LV_STATE_PRESSED);
    lv_obj_set_style_border_width(obj, 1, LV_STATE_DEFAULT);
    lv_obj_set_style_border_side(obj, LV_BORDER_SIDE_BOTTOM, LV_STATE_DEFAULT);
    lv_obj_set_style_border_color(obj, lv_color_hex(0xcccccc), LV_STATE_DEFAULT);

    // LV_TRACE_OBJ_CREATE("finished");
}

static void midea_base_scroll_btn_cell_destructor(const lv_obj_class_t *class_p, lv_obj_t *obj)
{
    LV_UNUSED(class_p);
    // if (obj->user_data != NULL) {
    //     lv_mem_free(obj->user_data);
    //     obj->user_data = NULL;
    //     printf("free user_data\n");
    // }
}

// #endif
